package com.ruoyi.wecom.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.business.domain.dto.admin.wecom.WecomGroupMemberPageQueryDTO;
import com.ruoyi.business.domain.vo.wecom.admin.CustomerChatGroupDetailVO;
import com.ruoyi.business.domain.wecom.TbWecomChatGroupMember;
import com.ruoyi.business.service.wecom.ITbWecomChatGroupMemberService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Validated
@Api(value = "企微群成员管理", tags = {"企微群成员管理"})
@RequiredArgsConstructor
@RestController
@RequestMapping("/wecom/group/member")
public class WecomGroupMemberController extends BaseController {

    @Resource
    private ITbWecomChatGroupMemberService tbWecomChatGroupMemberService;

    /**
     * 分页查询企微群成员列表
     */
    @ApiOperation("管理台分页查询企微群成员列表")
    @SaCheckPermission("wecom:group:member:page")
    @GetMapping("/sys-page")
    public TableDataInfo<TbWecomChatGroupMember> sysPage(WecomGroupMemberPageQueryDTO pageQueryDTO, PageQuery pageQuery) {
        return tbWecomChatGroupMemberService.sysPageQuery(pageQueryDTO, pageQuery);
    }

    /**
     * 客户详情-客户所在群聊列表
     */
    @ApiOperation("客户详情-客户所在群聊列表")
    @SaCheckPermission("wecom:group:member:query")
    @GetMapping("/sys-query-page")
    public TableDataInfo<CustomerChatGroupDetailVO> sysQueryPageByParam(
        @ApiParam("外部联系人id 或者 客服id") @RequestParam(required = false) String externalUserid, PageQuery pageQuery) {
        return tbWecomChatGroupMemberService.sysQueryPageByParam(externalUserid, pageQuery);
    }

}
